package gui.user;

import gui.alert;
import pojo.Guest;
import pojo.Guestroominfo;
import service.guestService;
import service.roomService;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class add_user {
    private JPanel add_room;
    private JButton confirm_add_Button;
    private JTextField name;
    private JTextField sex;
    private JTextField info;

    public add_user() {

        confirm_add_Button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                Guest guest = new Guest();
                guest.setBname(name.getText());
                guest.setBsex(sex.getText());
                guest.setInfo(info.getText());

                if (guestService.insert(guest)==1){
                    alert.show("添加成功");
                }else {
                    alert.show("添加失败");
                }
            }
        });
    }

    public static void show() {
        JFrame frame = new JFrame("增加用户");
        frame.setContentPane(new add_user().add_room);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

}
